/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class ListItem
    {
    
        private String listItemIdField;

        private String dateAddedField;

        private String commentField;

        private String quantityDesiredField;

        private String quantityReceivedField;

        private  Item itemField;

        /// <summary>
        /// Gets and sets the ListItemId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListItemId")]
        public String ListItemId
        {
            get { return this.listItemIdField ; }
            set { this.listItemIdField= value; }
        }



        /// <summary>
        /// Sets the ListItemId property
        /// </summary>
        /// <param name="listItemId">ListItemId property</param>
        /// <returns>this instance</returns>
        public ListItem WithListItemId(String listItemId)
        {
            this.listItemIdField = listItemId;
            return this;
        }



        /// <summary>
        /// Checks if ListItemId property is set
        /// </summary>
        /// <returns>true if ListItemId property is set</returns>
        public Boolean IsSetListItemId()
        {
            return  this.listItemIdField != null;

        }


        /// <summary>
        /// Gets and sets the DateAdded property.
        /// </summary>
        [XmlElementAttribute(ElementName = "DateAdded")]
        public String DateAdded
        {
            get { return this.dateAddedField ; }
            set { this.dateAddedField= value; }
        }



        /// <summary>
        /// Sets the DateAdded property
        /// </summary>
        /// <param name="dateAdded">DateAdded property</param>
        /// <returns>this instance</returns>
        public ListItem WithDateAdded(String dateAdded)
        {
            this.dateAddedField = dateAdded;
            return this;
        }



        /// <summary>
        /// Checks if DateAdded property is set
        /// </summary>
        /// <returns>true if DateAdded property is set</returns>
        public Boolean IsSetDateAdded()
        {
            return  this.dateAddedField != null;

        }


        /// <summary>
        /// Gets and sets the Comment property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Comment")]
        public String Comment
        {
            get { return this.commentField ; }
            set { this.commentField= value; }
        }



        /// <summary>
        /// Sets the Comment property
        /// </summary>
        /// <param name="comment">Comment property</param>
        /// <returns>this instance</returns>
        public ListItem WithComment(String comment)
        {
            this.commentField = comment;
            return this;
        }



        /// <summary>
        /// Checks if Comment property is set
        /// </summary>
        /// <returns>true if Comment property is set</returns>
        public Boolean IsSetComment()
        {
            return  this.commentField != null;

        }


        /// <summary>
        /// Gets and sets the QuantityDesired property.
        /// </summary>
        [XmlElementAttribute(ElementName = "QuantityDesired")]
        public String QuantityDesired
        {
            get { return this.quantityDesiredField ; }
            set { this.quantityDesiredField= value; }
        }



        /// <summary>
        /// Sets the QuantityDesired property
        /// </summary>
        /// <param name="quantityDesired">QuantityDesired property</param>
        /// <returns>this instance</returns>
        public ListItem WithQuantityDesired(String quantityDesired)
        {
            this.quantityDesiredField = quantityDesired;
            return this;
        }



        /// <summary>
        /// Checks if QuantityDesired property is set
        /// </summary>
        /// <returns>true if QuantityDesired property is set</returns>
        public Boolean IsSetQuantityDesired()
        {
            return  this.quantityDesiredField != null;

        }


        /// <summary>
        /// Gets and sets the QuantityReceived property.
        /// </summary>
        [XmlElementAttribute(ElementName = "QuantityReceived")]
        public String QuantityReceived
        {
            get { return this.quantityReceivedField ; }
            set { this.quantityReceivedField= value; }
        }



        /// <summary>
        /// Sets the QuantityReceived property
        /// </summary>
        /// <param name="quantityReceived">QuantityReceived property</param>
        /// <returns>this instance</returns>
        public ListItem WithQuantityReceived(String quantityReceived)
        {
            this.quantityReceivedField = quantityReceived;
            return this;
        }



        /// <summary>
        /// Checks if QuantityReceived property is set
        /// </summary>
        /// <returns>true if QuantityReceived property is set</returns>
        public Boolean IsSetQuantityReceived()
        {
            return  this.quantityReceivedField != null;

        }


        /// <summary>
        /// Gets and sets the Item property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Item")]
        public Item Item
        {
            get { return this.itemField ; }
            set { this.itemField = value; }
        }



        /// <summary>
        /// Sets the Item property
        /// </summary>
        /// <param name="item">Item property</param>
        /// <returns>this instance</returns>
        public ListItem WithItem(Item item)
        {
            this.itemField = item;
            return this;
        }



        /// <summary>
        /// Checks if Item property is set
        /// </summary>
        /// <returns>true if Item property is set</returns>
        public Boolean IsSetItem()
        {
            return this.itemField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetListItemId()) {
                xml.Append("<ListItemId>");
                xml.Append(EscapeXML(this.ListItemId));
                xml.Append("</ListItemId>");
            }
            if (IsSetDateAdded()) {
                xml.Append("<DateAdded>");
                xml.Append(EscapeXML(this.DateAdded));
                xml.Append("</DateAdded>");
            }
            if (IsSetComment()) {
                xml.Append("<Comment>");
                xml.Append(EscapeXML(this.Comment));
                xml.Append("</Comment>");
            }
            if (IsSetQuantityDesired()) {
                xml.Append("<QuantityDesired>");
                xml.Append(EscapeXML(this.QuantityDesired));
                xml.Append("</QuantityDesired>");
            }
            if (IsSetQuantityReceived()) {
                xml.Append("<QuantityReceived>");
                xml.Append(EscapeXML(this.QuantityReceived));
                xml.Append("</QuantityReceived>");
            }
            if (IsSetItem()) {
                Item  item = this.Item;
                xml.Append("<Item>");
                xml.Append(item.ToXMLFragment());
                xml.Append("</Item>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}